package com.example.demo;

import com.example.demo.config.SystemInterceptor;
import com.example.demo.config.annotation.EnableGlobalRedis;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author 张露晨
 * @date 2017/9/27 10:08.
 */
@SpringBootApplication
@EnableGlobalRedis
@MapperScan("com.example.demo.mapper") //扫描mapper
public class DemoApplication  extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }


    @Bean
    public SystemInterceptor getMyInterceptor(){
        return new SystemInterceptor();
    }

    /**
     * 配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getMyInterceptor()).addPathPatterns("/**").excludePathPatterns("/controller");
    }
}
